#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>

int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    printf("i am child process\n");
    sleep(5);
    exit(5);
  }

  int status = 0;
  int ret = 0;
  int sec = 0;
  while(ret = waitpid(id, &status, WNOHANG) == 0);

  printf("codedump: %d\n",status & 0x80);
  printf("sig_code: %d\n", status & 0x7f);
  printf("exit_code: %d\n",(status >> 8) & 0xff);
  return 0;
}
